package blackjack;

import java.util.ArrayList;
import java.util.Random;
/**
 * Created by musing on 1/6/14.
 */
public class Player {

    private ArrayList<Card> cards;

    public Player(){
        cards = new ArrayList<Card>();
    }

    public int draw(Random random){
        Card newDrawnCard = new Card(random);
        this.cards.add(newDrawnCard);
        return newDrawnCard.getValue();
    }

    public boolean busts(){
        int sum = 0;
        for(Card card: cards){
            sum += card.getValue();
            if (sum > 21){
                return true;
            }
        }
        return false;

    }

    public int getCard(int cardIndex){
        return this.cards.get(cardIndex).getValue();
    }

    public int getTotal(){
        int total = 0;
        for(Card card : cards){
            total += card.getValue();
        }
        return total;
    }
}
